<?php
class C_trackingdet extends CI_Controller {
	function __construct(){
		parent::__construct();
		checkLogin();
		$this->load->model('m_trackingdet');
	}
	function index(){
		$task = secure_post('task');
		switch($task){
			case 'LIST' :
				$this->_list();
				break;
			case 'INSERT' :
				$this->_insert();
				break;
			case 'UPDATE' :
				$this->_update();
				break;
			case 'DELETE' :
				$this->_delete();
				break;
			default :
				$this->load->view('v_trackingdet');
		}
	}
	
	function _list(){
		$data['page'] = numeric_post("page");
		$data['rows'] = numeric_post("rows");
		$data['m_flowdetchecklist_id'] = nosql_post("m_flowdetchecklist_id");
		$data['t_tracking_id'] = nosql_post("t_tracking_id");
		$data['trackingdet_flag'] = nosql_post("trackingdet_flag");
		echo $this->m_trackingdet->_list($data);
	}
	
	function _insert(){
		$data = array(
			'm_flowdetchecklist_id' => $this->input->post('m_flowdetchecklist_id'), 
			't_tracking_id' => $this->input->post('t_tracking_id'), 
			'trackingdet_flag' => $this->input->post('trackingdet_flag'), 
			  
			'trackingdet_insert_user'	=>$_SESSION[SESSION_USERNAMA],
			'trackingdet_insert_date'=> date("Y-m-d h:i:s"));
		$this->m_trackingdet->_insert($data);
		echo 1;
	}
	
	function _update(){
		$trackingdet_id = $this->input->post('trackingdet_id');
		$data = array(
			'm_flowdetchecklist_id' => $this->input->post('m_flowdetchecklist_id'), 
			't_tracking_id' => $this->input->post('t_tracking_id'), 
			'trackingdet_flag' => $this->input->post('trackingdet_flag'), 
			
			'trackingdet_update_user'	=>$_SESSION[SESSION_USERNAMA],
			'trackingdet_update_date'=> date("Y-m-d h:i:s"));
		$this->m_trackingdet->_update($data,$trackingdet_id);
		echo 1;
 	}
	
	function _delete(){
		$trackingdet_id= $this->input->post('trackingdet_id');
		$data = array(
			'trackingdet_id' => $trackingdet_id
		);
		$this->m_trackingdet->_delete($data);
		echo 1;
	}
}